package com.lixin.smartclassroom.ui.home.tab2.activity

import com.drake.brv.utils.bindingAdapter
import com.drake.channel.sendEvent
import com.drake.net.utils.scopeNetLife
import com.lixin.smartclassroom.api.coursegrouip
import com.lixin.smartclassroom.api.jingcailist
import com.lixin.smartclassroom.bean.DataListBean
import com.lixin.smartclassroom.databinding.ActivityAllGroupBinding
import com.lixin.smartclassroom.ext.allGroupIdList
import com.lixin.smartclassroom.ui.home.adapter.excitingMomentList
import com.lixin.smartclassroom.ui.home.adapter.groupScore
import com.lixinkeji.base.BaseActivity
import com.lixinkeji.extension.getIntentString
import com.lixinkeji.extension.gone
import com.lixinkeji.extension.onClick
import com.lixinkeji.extension.visible

/**
 * Description 所有分组
 * Author: lwc
 * Date:2023/12/8 14:06
 */
class AllGroupAct : BaseActivity<ActivityAllGroupBinding>() {
    override fun getViewBinding() = ActivityAllGroupBinding.inflate(layoutInflater)

    override fun topBarHide() = true
    override fun startPadding() = false
    private lateinit var listBean: ArrayList<DataListBean>
    private var courseid = ""


    override fun iniView() {
        allGroupIdList = ""
        courseid = getIntentString("courseid")
        binding.recycler.groupScore()



        binding.apply {
            refresh.onRefresh {
                scopeNetLife {
                    listBean = coursegrouip(courseid, index, 10)!!
                    if (index == 1) {
                        sendEvent("cs", "removeTag")
                    }
                    addData(listBean) {
                        if (binding.recycler.bindingAdapter.models?.size == 0) {
                            binding.state.showEmpty()
                            binding.recycler.gone()
                        } else {
                            binding.recycler.visible()
                        }
                        listBean.size == 10
                    }
                }
            }.autoRefresh()
        }

    }

    override fun onClick() {
        binding.apply {
            ivBack.onClick {
                finish()
            }
        }
    }

}